<template>
  <div class="my-container">
    <!-- 顶部导航start -->
    <header>猫眼电影</header>
    <!-- 顶部导航end -->
    <!-- main start -->
    <main>
      <div class="mv-city" @click="goToCityPicker">
        {{ cityName }}<i class="iconfont icon-xiajiantou"></i>
      </div>
      <div class="border"></div>
      <div class="mv-tabs">
        <van-tabs v-model="active">
          <van-tab title="热映">
            <MovieBody :active="active">
              <!-- <template #default="{ list }">
                <HotMovies :list="list"></HotMovies>
              </template> -->
            </MovieBody>
          </van-tab>
          <van-tab title="待映">
            <MovieBody :active="active">
              <!-- <template #default="{ list }">
                <ComingMovies :list="list"></ComingMovies>
              </template> -->
            </MovieBody>
          </van-tab>
        </van-tabs>
      </div>
      <div class="search"><i class="iconfont icon-sousuo"></i></div>
    </main>
    <!-- main end -->
  </div>
</template>

<script>
import Vue from "vue";
import { Tab, Tabs } from "vant";
import MovieBody from "@/components/MovieBody.vue";
import HotMovies from "./HotMovies.vue";
import ComingMovies from "./ComingMovies.vue";
Vue.use(Tab);
Vue.use(Tabs);
export default {
  components: { MovieBody, ComingMovies, HotMovies },
  data() {
    return {
      active: 1,
      type: "hot",
    };
  },
  computed: {
    cityName: function () {
      return localStorage.getItem("cityName") || "广州";
    },
  },
  methods: {
    goToCityPicker() {
      this.$router.push({
        name: "citypicker",
      });
    },
    HotType() {
      this.type = "hot";
    },
    ComingType() {
      this.type = "Coming";
    },
  },
};
</script>

<style lang="less" scoped>
@import url("@/assets/border.less");
.my-container {
  header {
    height: 0.45rem;
    line-height: 0.45rem;
    background-color: #cc4c43;
    color: white;
    text-align: center;
    font-size: 0.16rem;
    font-weight: bold;
  }

  main {
    position: relative;
    .mv-city {
      position: absolute;
      z-index: 999;
      left: 0.15rem;
      height: 0.45rem;
      display: flex;
      align-items: center;
      i.iconfont.icon-xiajiantou {
        font-size: 0.12rem;
        margin-left: 0.02rem;
      }
    }

    .border {
      position: absolute !important;
      width: 100%;
      height: 0.45rem;
      .border-1px(0 0 1px 0);
    }

    .mv-tabs {
    }

    .search {
      display: flex;
      align-items: center;
      justify-content: center;
      position: absolute !important;
      top: 0;
      bottom: 0;
      right: 0;
      height: 0.45rem;
      width: 0.45rem;
      .border-1px(0 0 0 1px);
      i {
        font-size: 0.2rem;
        color: #cc4c43;
        font-weight: bold;
      }
    }
  }
}
</style>
<style>
.van-tabs__wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 0.1rem;
}
.van-tabs {
  height: 100%;
}
.van-tabs__line {
  bottom: 0.09rem;
}
.van-tabs__nav {
  width: 60%;
}
.van-tabs__content {
  height: calc(100vh - 0.5rem);
}
.van-tab__pane {
  height: 100%;
  overflow-y: scroll;
}
</style>